<?php
session_start();
?>
<?php

	include_once('config/db_conn.php');
	include_once('db_config/db_gigs.php');
	include_once('db_config/db_user.php');
	include_once('db_config/db_order_payment.php');
	include_once('db_config/db_user_transaction.php');
	include_once('db_config/db_review.php');
	include_once('db_config/db_websetting.php');

	if($_SESSION['user_id'] == '')
		reDirect('index.php');

	$websetting= new websetting();
	$websetting_id = '1';
	$rs_websetting=$websetting->uniq_websettings('websetting_id',$websetting_id);
	$data_websetting=mysql_fetch_array($rs_websetting);

	$trans=new trans();
	$review=new review();

	$rs_trans=$trans->uniq_trans_list('user_id',$_SESSION['user_id']);

	$data_trans=mysql_fetch_array($rs_trans);

	$rs_trans_sum_pending_fund=$trans->sum_trans('pending_fund',$_SESSION['user_id']);
	$data_trans_sum_pending_fund=mysql_fetch_array($rs_trans_sum_pending_fund);

	$rs_trans_sum_withdraw=$trans->sum_trans('withdraw_request_ammount',$_SESSION['user_id']);
	$data_trans_sum_withdraw=mysql_fetch_array($rs_trans_sum_withdraw);

	$data_trans=mysql_fetch_array($rs_trans);

	//echo $data_trans['pending_fund'];
	$user=new user();
	$gigs=new gigs();
	$order_payment=new order_payment();
	if(@$_REQUEST['st'])
	{
		$rs=$order_payment->uniq_order_payment_list_double('seller_id',$_SESSION['user_id'],'order_status',$_REQUEST['st']);
	}
	else
	{
		$rs=$order_payment->uniq_order_payment_list('seller_id',$_SESSION['user_id']);
	}

	$rs_review_list_by=$review->review_list("review_by",$_SESSION['user_id']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $data_websetting['change_title']; ?></title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/custom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="javascript/jquery.min.js"></script>
<script type="text/javascript" src="javascript/jquery.simplemodal.js"></script>
<script type="text/javascript" src="javascript/init.js"></script>
<script type="text/javascript" src="javascript/init1.js"></script>
<script src="javascript/main.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">

	/* this is just a simple reload; you can safely remove it; remember to remove it from the image too */

	function reloadCaptcha()
	{
		document.getElementById('captcha').src = document.getElementById('captcha').src+ '?' +new Date();
	}
</script>
<script language="javascript">
function openCenteredWindow(url) {
	parms = 'menubar=no,width=600,height=500,toolbar=no'
	name = "facebook_share"
	height=500
	width=600
   var left = Math.floor( (screen.width - width) / 2);
   var top = Math.floor( (screen.height - height) / 2);
   var winParms = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;
   if (parms) { winParms += "," + parms; }
   var win = window.open(url, name, winParms);
   if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
   return win;
}
</script>

</head>
<body>
<div id="container" class="content">

<!--HEADER AREA-->
<?php include('header.php')?>
<!--HEADER AREA END-->
<div id="main" class="clearfix">
	<div class="main-tl">
	  	<div class="main-tr"></div>
	  	<div class="main-top"></div>
	</div>
	<div class="main-inner clearfix">
		<div class="side1">
		<!-- side1 content BEGIN ============================================================================= -->
<div class="gigOrders index js-response js-responses">
	<h2>Manage Work</h2>
	<div class="clearfix balance-information-block">
		<div class="balance-info">
			<!--<div class="balance-l"><span>You have: </span>$0.00 in your balance.</div>-->
			<div class="balance-r"><a href="sales_balance.php" title="My Balance">My Balance</a></div>
		</div>
	</div>
<!--
<div class="select-block">
	<div class="inbox-option">
		<span class="select">Select:</span>
		<a href="/gig_orders/type:myorders" class="" title="All">All</a>, <a href="/gig_orders/type:myorders/status:active" class="status_selected" title="Active">Active</a>, <a href="/gig_orders/type:myorders/status:rejected" class="" title="Rejected">Rejected</a>, <a href="/gig_orders/type:myorders/status:cancelled" class="" title="Cancelled">Cancelled</a>, <a href="/gig_orders/type:myorders/status:cancelled_late_orders" class="" title="Cancelled Late Orders">Cancelled Late Orders</a>, <a href="/gig_orders/type:myorders/status:waiting_for_acceptance" class="" title="Pending seller accept">Pending seller accept</a>, <a href="/gig_orders/type:myorders/status:in_progress" class="" title="In progress">In progress</a>, <a href="/gig_orders/type:myorders/status:waiting_for_review" class="" title="Waiting for your review">Waiting for your review</a>, <a href="/gig_orders/type:myorders/status:completed" class="" title="Complete">Complete</a>		
	</div>
</div>

<div><p class="paging-count">
Page 0 of 1, showing 0 records out of 0 total, starting on record 0</p>
</div>
<table class="revenues-list">
	<tbody><tr>
		<th>Date</th>
		<th>Order</th>
		<th>Status</th>
		<th>Action</th>
	</tr>
<tr>
	<td colspan="7"><p class="notice">No Orders available</p></td>
</tr>
</tbody></table>
-->

<?php
		  if(@$_REQUEST['st']!="review")
		  {
		   ?>
          <table class="revenues-list">
            <tr bgcolor="#F1F1F1" height="30">
              <th width="15%">Date</th>
              <th width="31%">Order Item </th>              
			  <th align="center" colspan="2">Status</th>
			  <th width="20%" align="center">Buyer</th>
		      <th align="center">Action</th>

             <!-- <td width="9%" align="center"><strong>Review</strong></td>-->
            </tr>
			<tr  >
              <td><?php if(@$_REQUEST['success']!='') echo 'Withdraw request  has taken successfully' ?></td>
            </tr>
            <?php
			$payment_gross=0;
 while($data=mysql_fetch_array($rs))
 {
$ct= count($data[1]);$rs_review=$review->uniq_review_list("order_id",$data['order_id']);$data_review=mysql_num_rows($rs_review);

$buyer_id  = $data['buyer_id'];
$user=new user();
$rs_user=$user->uniq_user_list('user_id',$buyer_id);
$data_buyer=mysql_fetch_array($rs_user);

$gigs=new gigs();
$rs_gigs_m=$gigs->uniq_gigs_list('gigs_title',$data['item_name']);
$data_m=mysql_fetch_array($rs_gigs_m);

?>
            <tr  >
              <td><?php echo $data['payment_date']; ?></td>
              <td><?php echo $data['item_name']; ?></td>
              <td align="center"><?php echo $data['order_status']; ?></td>
		      <td width="13%" ><!--<img src="images/actions.png" align="middle" onclick="javascript:location.href='edit_manage_order.php?orderid=<?php echo $data['order_id'];  ?>'" style="cursor:pointer;" />-->
			  <?php
			  if($data['order_status']!="compleated")
			  {
			  ?>
			  <a href="edit_manage_order.php?orderid=<?php echo $data['order_id'];  ?>">Cancel</a>
			  <?php
			  }
			  ?>
			  </td>
              <td align="center"><a href="new_messages.php?gig_id=<?=$data_m['id'];?>&to=<?=$data_buyer['user_name'];?>"><?=$data_buyer['user_name']?></a></td>
			  
			  <td width="12%" ><!--<img src="images/actions.png" align="middle" onclick="javascript:location.href='edit_manage_order.php?orderid=<?php echo $data['order_id'];  ?>'" style="cursor:pointer;" />-->
			  <?php
			  if($data['order_status']!="compleated" && $data['order_status']!="cancelled")
			  {
			  ?><a href="deliver_work.php?gig_title=<?php echo $data['item_name'];?>&orderid=<?php echo base64_encode($data['order_id']);  ?>" >Deliver Work</a>
			  <?php
			  }
			  else
			  {
			  ?>
			  Delivered
			  <?php
			  }
			  ?>
			  </td>
              <!--<td ><?php if($data_review==0){ ?><a href="review.php?orderid=<?php echo $data['order_id'];  ?>" >Give Review to seller </a><?php }else { echo "Review already given";} ?></td>-->
            </tr>
            <?php
		$payment_gross = $payment_gross+$data['payment_gross'];
 }
  ?>
  			<tr >
              <td colspan="5" align="left" style="font-weight:bolder;">
			  <?php
			  echo '<span style="font-weight:normal">You have:</span> $'.$payment_gross. ' in your balance';

			  ?>			  </td>
            </tr>
  			<tr height="100" >
              <td colspan="5" align="center">
			  <?php

			  if(@$ct==0)
			  {
			  ?>
			  <p class="notice">No records found ! </p>
			  <?php
			  }
			  ?>			  </td>
            </tr>



          </table>

		  <?php
		  }
		  if(@$_REQUEST['st']=="review")
		  {
		   ?>
		  <h2>Review</h2>
		  <table class="revenues-list">
            <tr bgcolor="#F1F1F1" height="30">
              <th width="13%">SL NO </th>
              <th width="48%">Shopp Orde Item </th>
              <th width="21%">Review To </th>
              <th colspan="3" align="center">Review</th>
	        </tr>

            <?php
			$k=0;
 while($data_review_list_by=mysql_fetch_array($rs_review_list_by))
 {

 $rs_gigs1=$gigs->uniq_gigs_list("id",$data_review_list_by['gigs_id']);
 $data_gigs1=mysql_fetch_array($rs_gigs1);

	?>
            <tr  >
			 <td><?php echo $k+1; ?></td>
              <td><?php echo $data_gigs1['gigs_title'] ?></td>



              <td><?php
			  $rs_user1=$user->uniq_user_list("user_id",$data_review_list_by['review_to']);
			  $data_user1=mysql_fetch_array($rs_user1);
			  echo $data_user1['user_name']."(".$data_user1['user_primary_email'].")";
			  ?></td>
              <td width="18%" colspan="3" align="center"><?php echo $data_review_list_by['review']; ?></td>
            </tr>
            <?php
		$k++;

 }
  ?>
  <tr height="100" >
              <td colspan="6" align="center">&nbsp;			 		  </td>
            </tr>
          </table>
		  <?php
		  }
		  ?>
</div><!-- end gigOrders -->
				
		<!-- side1 content END ============================================================================= -->
		</div><!-- end side1 -->
		<!-- side1 END ====================== -->
		<!-- side2 BEGIN ====================== -->
		<?php include('right.php'); ?>
		<!-- side2 END ====================== -->
	</div><!-- end main-inner-->
</div><!-- end main -->

<!--FOOTER AREA-->
<?php include('footer.php');?>
 <!--FOOTER AREA END-->

</div><!-- end container -->
</body>
</html>